﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace FileWatcher
{
    class Wacther
    {
        static void fileWatcher_Changed(Object sender, FileSystemEventArgs e)
        {
            using (StreamReader inFile = new StreamReader("filetowatch.txt"))
            {
                Console.WriteLine(inFile.ReadToEnd());
            }
        }

        static void Main()
        {
            FileSystemWatcher fileWatcher = new FileSystemWatcher();
            fileWatcher.Path = @"C:\Users\Academy\Documents\Visual Studio 2010\" +
                @"Projects\netessentials\TestGeneratorAIMI\StreamExercise\FileWatcher\bin\Debug";
            fileWatcher.Filter = "*.txt";
            fileWatcher.NotifyFilter = NotifyFilters.Size;
            
            fileWatcher.Changed += new FileSystemEventHandler(fileWatcher_Changed);

            fileWatcher.EnableRaisingEvents = true;

            Console.WriteLine("Press Q to quit.");
            while (Console.Read() != 'q')
            { }
        }
    }
}
